'use strict';
module.exports = dc => {
  const sequelize = dc.orm;
  const DataTypes = dc.ORM;
  const SoftwareCopyright = sequelize.define('SoftwareCopyright', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
      comment: '序号（手动维护）'
    },
    case_number: {
      type: DataTypes.STRING(100),
      comment: '我司案号'
    },
    software_name: {
      type: DataTypes.STRING(255),
      allowNull: false,
      comment: '软件名称'
    },
    inventors: {
      type: DataTypes.TEXT,
      comment: '发明人'
    },
    disclosure_time: {
      type: DataTypes.DATEONLY,
      comment: '技术交底书收集时间'
    },
    development_complete_date: {
      type: DataTypes.DATEONLY,
      comment: '开发完成日期'
    },
    acceptance_date: {
      type: DataTypes.DATEONLY,
      comment: '受理时间'
    },
    issue_date: {
      type: DataTypes.DATEONLY,
      comment: '发证时间'
    },
    registration_number: {
      type: DataTypes.STRING(100),
      comment: '登记号'
    },
    related_product: {
      type: DataTypes.STRING(255),
      comment: '关联产品'
    },
    related_project: {
      type: DataTypes.STRING(255),
      comment: '关联立项/课题'
    },
    type: {
      type: DataTypes.STRING(50),
      comment: '防御型/攻击型'
    },
    first_publication_date: {
      type: DataTypes.DATEONLY,
      comment: '首次发表日期'
    },
    copyright_holder: {
      type: DataTypes.STRING(255),
      comment: '著作权人'
    },
    status: {
      type: DataTypes.STRING(50),
      comment: '状态'
    },
    is_core: {
      type: DataTypes.BOOLEAN,
      comment: '是否为核心'
    },
    core_score: {
      type: DataTypes.DECIMAL(5, 2),
      comment: '核心分数'
    },
    source_department: {
      type: DataTypes.STRING(100),
      comment: '来源部门'
    },
    agent_responsible: {
      type: DataTypes.STRING(100),
      comment: '代理负责人'
    },
    original_name: {
      type: DataTypes.STRING(255),
      comment: '原名称'
    },
    special_notes: {
      type: DataTypes.TEXT,
      comment: '特殊事项备注'
    },
    dev_related_project: {
      type: DataTypes.STRING(255),
      comment: '（发展部）关联课题/项目'
    }
  }, {
    tableName: 'software_copyright',
    timestamps: false,
    indexes: [
      {
        unique: true,
        fields: ['software_name', 'registration_number'],
        name: 'unique_software_registration'
      }
    ]
  });

  dc.models.SoftwareCopyright = SoftwareCopyright;
  return SoftwareCopyright;
}; 